package com.movitech.mobile.cz.base.purchase.service.impl;

import com.movitech.mobile.cz.base.common.license.LicenseUtil;
import com.movitech.mobile.cz.base.purchase.entity.WFlowFormAwardBid;
import com.movitech.mobile.cz.base.purchase.entity.ext.ExtWFlowFormAwardBid;
import com.movitech.mobile.cz.base.purchase.mapper.WFlowFormAwardBidMapper;
import com.movitech.mobile.cz.base.purchase.mapper.ext.ExtWFlowFormAwardBidMapper;
import com.movitech.mobile.cz.base.purchase.service.WFlowFormAwardBidService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 中标流程表单-中标 服务实现类
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-03-19
 */
@Service
public class WFlowFormAwardBidServiceImpl extends ServiceImpl<WFlowFormAwardBidMapper, WFlowFormAwardBid> implements WFlowFormAwardBidService {

	@Autowired
	private ExtWFlowFormAwardBidMapper extWFlowFormAwardBidMapper;

	@Override
	public WFlowFormAwardBid getSupplierAwardBidBySupplierIdAndCooperationYears(String supplierId, int cooperationYears) {
		return extWFlowFormAwardBidMapper.getSupplierAwardBidBySupplierIdAndCooperationYears(supplierId, cooperationYears);
	}

	@Override
	public List<Map<String,Object>> getSupplierAwardBidsUnSyn() {
		return extWFlowFormAwardBidMapper.getSupplierAwardBidsUnSyn();
	}

	@Override
	public void updateSynStatus(String id) {
		LicenseUtil.INSTANCE.validate();
		WFlowFormAwardBid bid = new WFlowFormAwardBid();
		bid.setId(id);
		bid.setSynStatus(1);
		bid.setSynTime(new Date());
		extWFlowFormAwardBidMapper.updateById(bid);
	}
}
